<html>
<head>
<!--
<script src = "../../build/yahoo/yahoo.js" ></script>
-->
<script src = "../src/js/YAHOO.js" ></script>
<script src = "../../build/event/event.js" ></script>
<script src = "../../build/dom/dom.js" ></script>
<script src = "../../build/connection/connection.js" ></script>
<script src = "../../build/dragdrop/dragdrop.js" ></script>
<script src = "../../build/logger/logger.js" ></script>
<script type="text/javascript">

YAHOO.widget.Logger.enableBrowserConsole() 
var l = new YAHOO.widget.LogWriter("(");

YAHOO.example.LangTest = function() {
    function log(msg,cat) {
        var c=c||"info";
        YAHOO.log(msg,c,"LangTest");
    }

    var tests = {

        "An array literal is an array": 
            YAHOO.lang.isArray([1, 2]),

        "An object literal is not an array": 
            !YAHOO.lang.isArray({"one": "two"}),

        "But, an associative array is an array": 
            function() {
                var a = new Array();
                a["one"] = "two";
                return YAHOO.lang.isArray(a);
            }(),

        "A collection of elements is like an array, but isn't": 
            !YAHOO.lang.isArray(document.getElementsByTagName("body")),

        "null is not an array": 
            !YAHOO.lang.isArray(null),

        "True/false is a boolean":
            YAHOO.lang.isBoolean(false),

        "1/0 are not boolean values":
            !YAHOO.lang.isBoolean(1),

        "'true'/'false' are not boolean values":
            !YAHOO.lang.isBoolean("true"),

        "a function is a function":
            YAHOO.lang.isFunction(function(){}),

        "an object is not a function":
            !YAHOO.lang.isFunction({foo: "bar"}),

        "null is null":
            YAHOO.lang.isNull(null),

        "undefined is not null":
            !YAHOO.lang.isNull(undefined),

        "'' is not null":
            !YAHOO.lang.isNull(""),

        "0 is a number":
            YAHOO.lang.isNumber(0),

        "123.123 is a number":
            YAHOO.lang.isNumber(123.123),

        "'123.123' is a not number":
            !YAHOO.lang.isNumber("123.123"),

        "100/0 is a not legal number":
            !YAHOO.lang.isNumber(1/0),

        "an object is an object":
            YAHOO.lang.isObject({}),

        "a function is an object":
            YAHOO.lang.isObject(function(){}),

        "an array is an object":
            YAHOO.lang.isObject([1,2]),

        "a number is not an object":
            !YAHOO.lang.isObject(1),

        "null is not an object":
            !YAHOO.lang.isObject(null),

        "a boolean is not an object":
            !YAHOO.lang.isObject(true),

        "a string is not an object":
            !YAHOO.lang.isObject("{}"),

        "a string is a string":
            YAHOO.lang.isString("{}"),

        "an object is not a string":
            !YAHOO.lang.isString({foo: "bar"}),

        "a number is not a string":
            !YAHOO.lang.isString(123),
  
        "a boolean is not a string":
            !YAHOO.lang.isString(true),
 
        "undefined is undefined***":
            YAHOO.lang.isUndefined(undefined),
 
        "false is not undefined":
            !YAHOO.lang.isUndefined(false),

        "null is not undefined":
            !YAHOO.lang.isUndefined(null)

    }

    return { 
        init: function() {

            alert(typeof null);

            for (var i in tests) {
                log(i + ": " + tests[i]);
            }


            // hasOwnProperty is true if the object has the property and its
            // value is not the same as what is defined in its prototype

            Object.prototype.myCustomFunction = function(foo) {
                alert(foo);
            }

            var o = {};
            o["foo"] = "bar";
            o["marco"] = "polo";

            for (var i in o) {
                if (YAHOO.lang.hasOwnProperty(o, i)) {
                    alert("good key: " + i);
                } else {
                    alert("bad key: " + i);
                }
            }

        }
    };
} ();


YAHOO.example.LangTest.init();

</script>
</head>
<body><style>.dd {position:absolute; height:50px; width:50px; border:1px solid green} 
  #ddel1 {top: 100px; left: 100px; background: red}
  #ddel2 {top: 100px; left: 200px; background: red}
  #ddel3 {top: 200px; left: 100px; background: blue}
  #ddel4 {top: 200px; left: 200px; background: blue}</style>
<div id="ddel1" class="dd"></div><div id="ddel2" class="dd"></div><div id="ddel3" class="dd"></div><div id="ddel4" class="dd"></div>
<input type="button" id="tester1" value="global" /><input type="button" id="tester2" value="sandboxed" />
</body>
</html>
